package com.tqfframe.task.learning.threadStudy;

/**
 * @Author: 唐祺峰
 * @Date: 2020/9/9 0009 15:58
 * @Version 1.0
 */
public class VolatileStudy {

    public static volatile int count=0;

    public static void main(String[] args) {
        TestClass testClass=new TestClass();
        new Thread(testClass,"t1").start();
        new Thread(testClass,"t2").start();
        new Thread(testClass,"t3").start();
        new Thread(testClass,"t4").start();
        new Thread(testClass,"t5").start();
    }

    static class TestClass implements Runnable{

        @Override
        public void run() {
            foo();
            System.out.println(Thread.currentThread().getName()+":" +count);
        }
    }

    public static void foo(){
        int i=10;
        while (i-->0){
            count++;
        }
    }

}
